package com.coderfans.databole;

import com.coderfans.utils.FilterHtmlTagUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import us.codecraft.xsoup.Xsoup;

import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;

/**
 * Created by 58-daojia on 2018-1-2.
 *
 * @author: fanchunshuai
 * @version: V1.0
 * @Desc:
 * @Copyright (c) 2018 58到家-版权所有
 */
public class BlogContent {
    public static void main(String[] args) {
        File file = new File("E:\\spiderFile\\jobbole\\blog\\3151.html");
        try {
            String contentTag = "//*[@id=\"post-3151\"]/div[3]";
            Document document = Jsoup.parse(file, "UTF-8");
            String content = Xsoup.compile(contentTag).evaluate(document).get();


            String s = FilterHtmlTagUtils.Html2Text(StringUtils.deleteWhitespace(content));
            System.out.println("s = " + s);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
